home *** CD-ROM | disk | FTP | other *** search
/ Basic Instinct 2 Press Kit / Basic Instinct 2 Press Kit.iso / pc / main.dxr / Internal_33_netQueue parent.ls < prev    next >
Encoding:
Text File  |  2006-03-15  |  2.7 KB  |  99 lines

  1. property pNetQueue, pNetProcess, pStartTimer, pMaxTime, pStepframe
  2. global gNetQueue, gTracker
  3.  
  4. on new me
  5.   pStartTimer = 0
  6.   pMaxTime = 900
  7.   pStepframe = "none"
  8.   pNetQueue = []
  9.   pNetProcess = []
  10.   (the actorList).add(me)
  11.   return me
  12. end
  13.  
  14. on mDestruct me
  15.   counter = pNetProcess.count
  16.   repeat with i = 1 to counter
  17.     pNetProcess[1].mDestruct()
  18.     pNetProcess[1] = 0
  19.     pNetProcess.deleteAt(1)
  20.   end repeat
  21.   counter = pNetQueue.count
  22.   repeat with i = 1 to counter
  23.     pNetQueue[1].mDestruct()
  24.     pNetQueue[1] = 0
  25.     pNetQueue.deleteAt(1)
  26.   end repeat
  27.   (the actorList).deleteOne(me)
  28. end
  29.  
  30. on mFileTheResults me, vResult
  31.   put vResult
  32.   gTracker.p12345 = vResult
  33.   pStepframe = "none"
  34. end
  35.  
  36. on mGetNetText me, url, callBackMethod, callBackObject
  37.   tempNetObject = new(script("netOperations parent"), #GET, url, callBackMethod, callBackObject)
  38.   me.mQueueNetObject(tempNetObject)
  39.   pStartTimer = the timer
  40. end
  41.  
  42. on mPostNetText me, url, propertyList, callBackMethod, callBackObject
  43.   tempNetObject = new(script("netOperations parent"), #POST, url, callBackMethod, callBackObject, propertyList)
  44.   me.mQueueNetObject(tempNetObject)
  45. end
  46.  
  47. on mPreloadNetThing me, url, callBackMethod, callBackObject
  48.   tempNetObject = new(script("netOperations parent"), #preload, url, callBackMethod, callBackObject)
  49.   me.mQueueNetObject(tempNetObject)
  50. end
  51.  
  52. on mDownloadNetThing me, url, localFile, callBackMethod, callBackObject
  53.   tempNetObject = new(script("netOperations parent"), #download, url, callBackMethod, callBackObject, VOID, localFile)
  54.   me.mQueueNetObject(tempNetObject)
  55. end
  56.  
  57. on mQueueNetObject me, whichObj
  58.   if pNetProcess.count < 4 then
  59.     whichObj.mExecuteNetCommand()
  60.     pNetProcess.append(whichObj)
  61.   else
  62.     pNetQueue.append(whichObj)
  63.   end if
  64. end
  65.  
  66. on stepFrame me
  67.   case pStepframe of
  68.     "none":
  69.       nothing()
  70.     "waiting":
  71.       if the timer > (pStartTimer + pMaxTime) then
  72.         pStepframe = "timed out"
  73.       end if
  74.       if pNetProcess.count then
  75.         counter = 1
  76.         repeat while counter <= pNetProcess.count
  77.           if pNetProcess[counter].mIsNetOpDone() then
  78.             pNetProcess[counter].mCallBackResults()
  79.             pNetProcess[counter].mDestruct()
  80.             pNetProcess[counter] = 0
  81.             pNetProcess.deleteAt(counter)
  82.             next repeat
  83.           end if
  84.           counter = counter + 1
  85.         end repeat
  86.         if (pNetProcess.count <= 4) and pNetQueue.count then
  87.           repeat while (pNetProcess.count < 4) and (pNetQueue.count <> 0)
  88.             pNetProcess.append(pNetQueue[1])
  89.             mExecuteNetCommand(pNetProcess.getLast())
  90.             pNetQueue.deleteAt(1)
  91.           end repeat
  92.         end if
  93.       end if
  94.     "timed out":
  95.       pStepframe = "none"
  96.       gTracker.p12345 = EMPTY
  97.   end case
  98. end
  99.